package com.qf.flash.ui.business;

import android.app.Activity;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.qf.flash.R;
import com.qf.flash.event.MoneySetEvent;
import com.qf.flashlib.app.FlashLib;
import com.qf.flashlib.base.BaseActivity;

import org.greenrobot.eventbus.EventBus;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 创建日期：2020/4/6 on 18:19
 * 描述:
 * 作者:戴旭东
 */
public class SetFeeActivity extends BaseActivity {
    @BindView(R.id.tv_top_title)
    TextView tvTopTitle;
    @BindView(R.id.ev_money)
    EditText evMoney;
    private String orderId;

    public static void start(Activity activity, String orderId) {
        Intent intent = new Intent(activity, SetFeeActivity.class);
        intent.putExtra("orderId", orderId);
        activity.startActivity(intent);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_set_fee;
    }

    @Override
    protected void initViewAndData() {
        tvTopTitle.setText("收款金额");
        orderId = getIntent().getStringExtra("orderId");
    }


    @OnClick({R.id.tv_top_back, R.id.tv_sure})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_top_back:
                finish();
                break;
            case R.id.tv_sure:
                if (TextUtils.isEmpty(evMoney.getText().toString().trim())) {
                    FlashLib.showToast("请输入金额");
                    return;
                }
                String money = evMoney.getText().toString().trim();
                EventBus.getDefault().post(new MoneySetEvent(Double.valueOf(money), orderId));
                finish();
                break;
        }
    }
}
